﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.EntityModel.Applications;
using YasharEl.Infrastructure.ProcessEngine.EntityModel;

namespace YasharEl.Infrastructure.ProcessEngine.PersistenceModel.NHibernate.Mappings
{
    public class ProcessDefinitionGroupEntityMap : ClassMap<ProcessDefinitionGroupEntity>
    {
        public ProcessDefinitionGroupEntityMap()
        {
            ReadOnly();

            Table("ProcessDefinitionGroups");

            Id(e => e.ProcessDefinitionGroupId)
                .Column("ProcessDefinitionGroupId")
                    .GeneratedBy.Assigned();

            Map(e => e.GroupName)
                .Column("GroupName")
                .Length(250)
                .Not.Nullable();

            Map(e => e.GroupDescription)
                .Column("GroupDescription")
                .Length(1000)
                .Not.Nullable();

            References(e => e.ParentGroup)
                .Column("ParentGroupId")
                .Class<ProcessDefinitionGroupEntity>()
                .LazyLoad();

            References(e => e.BelongsToApplication)
                .Column("ApplicationId")
                .Class<ApplicationEntity>()
                .LazyLoad();

            // TODO: Map direct childs references
        }
    }
}
